function [npop]=ganewpop(pop,order,nb)
global Disc Mutfact Survrate SelectMethod Ngeneration Npopulation Nselection
n=length(pop(:,1));

for i=1:Nselection
    npop(i,:)=pop(order(i),:);
end
k=Nselection+1;
while k<Survrate*n
    e=rand(1);

    if e<Mutfact %mutuation
                e=rand(1);
                
                if SelectMethod=='T'
                    e1=rand(1);
                    if e1>e
                        e=e1;
                    end
                else
                    if SelectMethod=='D'                        
                    e=e^(Disc);
                    end
                end
                
                i=n-fix(e*n);
                if i==0
                    i=1;
                end
                npop(k,:)=gamutation(pop(order(i),:));
                k=k+1;
    else

                e=rand(1);
                
                if SelectMethod=='T'
                    e1=rand(1);
                    if e1>e
                        e=e1;
                    end
                else
                    if SelectMethod=='D'                        
                    e=e^(Disc);
                    end
                end
                
                c1=n-fix(e*n);
                if c1==0
                    c1=1;
                end

                e=rand(1);
                
                if SelectMethod=='T'
                    e1=rand(1);
                    if e1>e
                        e=e1;
                    end
                else
                    if SelectMethod=='D'                        
                    e=e^(Disc);
                    end
                end

                c2=n-fix(e*n);
                if c2==0
                    c2=1;
                end

                [p,q]=gacrossover(pop(order(c1),:),pop(order(c2),:));
                npop(k,:)=p;
                npop(k+1,:)=q;
                k=k+2;
    end
end

while k<n
    npop(k,1:nb)=garandomstring(nb);
    k=k+1;
end
